<template>
        <div class="regbah">
            <ul class="zList">
                <li class="zl" v-for="(item, index) in list" :key="index" @mouseover="showYdiv(index)">
                    <router-link to="/">{{ item.name }}</router-link> 
                    <router-link to="/" v-for="i in item.children.slice(0, 2)" :key="i.id">{{ i.name }}</router-link>
                </li>
                <div class="ydiv">
                    <div class="sjop" v-for="(item, index) in list" :key="index" v-show="activeIndex === index">
                        <h4>分类推荐 <small>根据您的购买或浏览记录推荐</small></h4>
                        <ul>
                            <li class="ao" v-for="(i, v) in item.goods" :key="i.id">
                                <a href="/">
                                    <img :src="i.picture" alt="">
                                    <div class="info">
                                        <p class="name ellipsis-2">{{ i.name }}</p>
                                        <p class="desc ellipsis">{{ i.desc }}</p>
                                        <p class="price">
                                            <i>￥</i>{{ i.price }}
                                        </p>
                                    </div>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </ul>
        </div>
</template>

<script>
import { getCategory } from '@/request/api/myc/myc';

export default {
    data() {
        return {
            list: [],
            activeIndex:''
        };
    },
    mounted() {
        this.Category();


    },
    methods: {
        async Category() {
            const res = await getCategory();
            console.log("新鲜好物", res.data.result);
            this.list = res.data.result
        },
        showYdiv(index){
            this.activeIndex=index;
        }

    }
};
</script>

<style lang="scss" scoped>
.regbah {
    height: 450px;
    position: relative;
    top: 0;
    left: 0;
    // z-index: 20;
    display: flex;
}

.regbah .zList {
    width: 250px;
    background: rgba(0, 0, 0, .8);
    z-index: 20;
}

.regbah .zList .zl {
    padding-left: 40px;
    // margin-left: 40px;
    line-height: 50px;
    height: 50px;
}
.regbah .zList .zl a:first-child{
    font-size: 18px;
}
.regbah .zList .zl a {
    color: #fff;
}

.regbah .zList .zl:hover {
    background: #27ba9b;
}



.ydiv {
    position: relative;
    top: -450px;
    left: 250px;
    width: 990px;
    height: 450px;
    background: hsla(0, 0%, 100%, .8);
    display: none;
}

.zList:hover .ydiv {
    display: block;
}

.sjop {
    padding-left: 15px;

    h4 {
        font-size: 20px;
        font-weight: 400;
        line-height: 50px;

        small {
            font-size: 16px;
            color: #666;
        }
    }

    ul {
        display: flex;
        flex-wrap: wrap;

        .ao {
            width: 310px;
            height: 120px;
            margin-right: 15px;
            margin-bottom: 15px;
            border: 1px solid #eee;
            border-radius: 4px;
            background: #fff;

            a {
                display: flex;
                width: 100%;
                height: 100%;
                align-items: center;
                padding: 10px;

                img {
                    width: 95px;
                    height: 95px;
                }

                .info {
                    padding-left: 10px;
                    line-height: 24px;
                    width: 190px;
                    float: left;

                    .ellipsis-2 {
                        word-break: break-all;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        -webkit-line-clamp: 2;
                    }

                    .name {
                        font-size: 16px;
                        color: #666;
                    }

                    .desc {
                        color: #999;
                    }

                    .price {
                        font-size: 22px;
                        color: #cf4444;

                        i {
                            font-size: 16px;
                        }
                    }
                }
            }

            a:hover {
                background: #e3f9f4;
            }
        }

        .aihei {
            width: 310px;
            height: 180px;
            margin-right: 15px;
            margin-bottom: 15px;
            border: 1px solid #eee;
            border-radius: 4px;
            background: #fff;

            a {
                // display: flex-start;
                display: block;
                width: 100%;
                height: 100%;
                align-items: center;
                padding: 10px;

                img {
                    width: 120px;
                    height: 150px;
                    margin-top: 5px;
                }

                .info {
                    padding-left: 10px;
                    line-height: 24px;
                    width: 160px;
                    // display: inline-block;
                    float: right;

                    p {
                        margin-top: 8px;
                    }

                    .place {
                        color: #999;
                    }
                    .desc{
                        color: #999;
                    }
                    .name {
                        font-size: 16px;
                        color: #666;
                    }
                }
            }
            a:hover {
                background: #e3f9f4;
            }
        }
    }
}
</style>